import * as order from '@/api/order.js';
const state = {
	my_order_active:0
};
const mutations = {
	SET_MY_ORDER_ACTIVE(state,active){
		state.my_order_active = active
	}
};
const getters = {
	myOrderActive:state => state.my_order_active
};
const actions = {
	//取消订单
	cancelOrder({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.cancelOrder(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//确认收货
	confirmOrder({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.confirmOrder(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//获取订单详情
	orderDetail({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.orderDetail(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//订单首页
	orderIndex({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.orderIndex(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//获取订单列表
	orderList({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.orderList(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//待发货/待收货:订单列表
	listOrderShip({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.listOrderShip(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//待付款订单列表
	listOrderUnpay({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.listOrderUnpay(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	//订单提交
	orderSubmit({ commit }, payload = {}) {
		return new Promise((resolve, reject) => {
			order.orderSubmit(payload).then(res => {
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	}
};

export default { state, getters, mutations, actions };
